package com.io.printstream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;

/**
 * 演示PrintWriter使用方法
 */
public class PrintWriter_ {
    public static void main(String[] args) throws FileNotFoundException {
        // System.out 标准输出到命令框
        //PrintWriter pw = new PrintWriter(System.out);
        String path = "E:\\test\\print2.txt";
        // 把打印的内容写入到指定文件中
        PrintWriter pw = new PrintWriter(new FileOutputStream(path));
        pw.print("hi,广州！");
        pw.append("追加写入测试");
        // 关闭资源流,如果不关闭则无法写入内容 底层也是自动关闭 FileOutputStream资源流
        pw.close();
    }
}
